// 定制协议类
#pragma once

#include <iostream>
#include<memory>

using namespace std;
class Request
{
public:
    Request() : _data_x(0), _data_y(0), _oper(0)
    {
    }
    Request(int x, int y, char oper) : _data_x(x), _data_y(y), _oper(oper)
    {
    }
    void Debug()
    {
        std::cout << "Request: " << _data_x << " " << _data_y << " " << _oper << std::endl;
    }
    void Inc()
    {
        _data_x++;
        _data_y++;
    }

private:
    int _data_x; // 第一个参数
    int _data_y; // 第二个参数
    char _oper;  // 算数运算符 + - * / %
};

class Reponse
{
public:
    Reponse() : _result(0), _code(0)
    {
    }
    Reponse(int result, int code) : _result(result), _code(code)
    {
    }

private:
    int _result; // 运算结果
    int _code;   // 状态码
};

//工厂模式
class Factory
{
    public:
        shared_ptr<Request> BuildRequest()
        {
            shared_ptr<Request> req=make_shared<Request>();
            return req;
        }

        shared_ptr<Request>BuildRequest(int x, int y, char oper)
        {
            shared_ptr<Request> req=make_shared<Request>(x,y,oper);
            return req;
        }

        shared_ptr<Reponse> BuildReponse()
        {
            shared_ptr<Reponse> rep=make_shared<Reponse>();
            return rep;
        }
        shared_ptr<Reponse> BuildReponse(int result, int code)
        {
            shared_ptr<Reponse> rep=make_shared<Reponse>(result,code);
            return rep;
        }
};